package Model;
import java.util.ArrayList;

/**
 * Write a description of class Ordre here.
 * 
 * @author Gruppe 4 
 * @version 14/12/11
 */
public class Ordre
{
    private int ordreNr;
    private boolean leverOrdre;
    private boolean hentOrdre;
    private String status;
    private double totalPris;
    private String dato;
    private ArrayList<Delordre> delordre;
    private Ordre currentOrdre;

    /**
     * Constructor for the class
     */
    public Ordre(int ordreNr, String dato)
    {
        this.ordreNr = ordreNr;
        delordre = new ArrayList<Delordre>();
        this.dato = dato;
    }

    /**
     * this method returns ordreNr
     * 
     * @param nothing
     * @return ordreNr
     */
    public int getOrdreNr()
    {
        return ordreNr;
    }

    /**
     * this method returns leverOrdre
     * 
     * @param nothing
     * @return leverOrdre
     */
    public boolean getLeverOrdre()
    {
        return leverOrdre;
    }

    /**
     * this method returns hentOrdre
     * 
     * @param nothing
     * @return hentOrdre
     */
    public boolean getHentOrdre()
    {
        return hentOrdre;
    }

    /**
     * this method returns status
     * 
     * @param nothng
     * @return status
     */
    public String getStatus()
    {
        return status;
    }

    /**
     * this method returns totalPris
     * 
     * @param nothing
     * @return totalPris
     */
    public double getTotalPris()
    {
        for(Delordre d: delordre)
        {
            this.totalPris += d.calcTotalPris();
        }
        return totalPris;
    }

    /**
     * this method returns dato
     * 
     * @param nothing
     * @return dato
     */
    public String getDato()
    {
        return dato;
    }

    /**
     * this method can give ordreNr a new value
     * 
     * @param ordreNr
     * @return nothing
     */
    public void setOrdreNr(int ordreNr)
    {
        this.ordreNr=ordreNr;
    }

    /**
     * this method can give leverOrdre a new value
     * 
     * @param leverOrdre
     * @return nothing
     */
    public void setLeverOrdre(boolean leverOrdre)
    {
        this.leverOrdre = leverOrdre;
    }

    /**
     * this method can give hentOrdre a new value
     * 
     * @param hentOrdre
     * @return nothing
     */
    public void setHentordre(boolean hentOrdre)
    {
        this.hentOrdre = hentOrdre;
    }

    /**
     * this methoc can give status a new value
     * 
     * @param status
     * @return nothing
     */
    public void setStatus(String status)
    {
        this.status = status;
    }

    /**
     * this method can give dato a new value
     * 
     * @param dato
     * @reutn nothing
     */
    public void setDato(String dato)
    {
        this.dato=dato;
    }

    /**
     * this method can add a new Delorder to Order
     * 
     * @param Delordre Ordre
     * @return nothing
     */
    public void addDelordre(Delordre ordre)
    {
        delordre.add(ordre);
    }

    /**
     * this method can find a Delorder in Order
     * 
     * @param int delorderNr
     * @return Delorder d, or null
     */
    public Delordre findDelordre(int delordreNr)
    {
        int index = 0;
        Delordre rd = null;
        while(delordre.size() > index)
        {
            Delordre d = delordre.get(index);
            if(d.getDelOrdreNr() == (delordreNr))
            {
                rd = d;
            }
            index++;
        }
        return rd;
    }

    /**
     * this method can remove a Delordre from Oder
     * 
     * @param Delorder delorder
     * @return nothing
     */
    public void removeDelordre(int delordre)
    {
        this.delordre.remove(findDelordre(delordre));
    }

    /**
     * this mehod returns faktura for the whole ordre
     * 
     * @param nothing
     * @return delordre.get(nr).myFaktura()
     */
    public String myFaktura()
    {
        int nr = 0;
        nr = delordre.size();
        nr -= 1;
        return delordre.get(nr).myFaktura();
    }

    /**
     * this mehod returns calculate the whole price of the ordre
     * 
     * @param nothing
     * @return delordre.get(nr).calcTotalPris()
     */
    public double totalPris()
    {
        int nr = 0;
        nr = delordre.size();
        nr -= 1;
        return delordre.get(nr).calcTotalPris();
    }
}